
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[DimCustomer]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
 drop table [dbo].[DimCustomer]

GO

CREATE TABLE [dbo].[DimCustomer] (
	[CustomerKey] [int] IDENTITY (1, 1) NOT FOR REPLICATION NOT NULL,
	[CustomerIdentifier] [varchar] (30) NOT NULL,
	[FullName] [nvarchar] (150) NOT NULL,
	[NamePrefix] [nvarchar] (50) NOT NULL,
	[GivenName] [nvarchar] (50) NOT NULL,
	[FamilyName] [nvarchar] (50) NOT NULL,
	[MiddleName] [nvarchar] (50) NOT NULL,
	[NameSuffix] [varchar] (20) NOT NULL,
	[Initials] [varchar] (20) NOT NULL,
	[Nickname] [nvarchar] (50) NOT NULL,
	[MadienName] [nvarchar] (50) NOT NULL,
	[MarriedName] [nvarchar] (50) NOT NULL,
	[ProfessionalTitle] [nvarchar] (150) NOT NULL,
	[AcademicTitle] [nvarchar] (150) NOT NULL,
	[EmailAddress] [varchar] (256) NOT NULL,
	[EmailAddressDomain] [varchar] (150) NOT NULL,
	[DateOfBirth] [datetime] NOT NULL,
	[Age] [int] NOT NULL,
	[Gender] [nvarchar] (20) NOT NULL,
	[Locality] [nvarchar] (150) NOT NULL,
	[PhoneNumber] [varchar] (20) NOT NULL,
	[Nationality] [nvarchar] (50) NOT NULL,
	[SocialSecurityNumber] [varchar] (30) NOT NULL,
	[Relationship] [nvarchar] (30) NOT NULL,

	CONSTRAINT [PK_Customer] PRIMARY KEY CLUSTERED (
		   [CustomerKey])

)

GO

grant references, select, insert, delete, update on [dbo].[DimCustomer] to [db_datawriter]

GO

grant select on [dbo].[DimCustomer] to [public]

GO

